package code20211117;

import java.util.ArrayList;
import java.util.List;

public class C318 {

	public static void main(String[] args) {
		String[] words = {"a","ab","abc","d","cd","bcd","abcd"};
		System.out.println(new C318().maxProduct(words));

	}
	public int maxProduct(String[] words) {
        int n = words.length;
        int max = 0;
        for(int i=0;i<n;i++){
        	String s1 = words[i];
        	for(int j=i+1;j<n;j++) {
        		String s2 = words[j];
        		if(isReparting(s1,s2)) {
        			max = s1.length()*s2.length()>max?s1.length()*s2.length():max;
        		}
        	}
        }
        return max;
    }
    public boolean isReparting(String str1,String str2){
        List<Character> lists = new ArrayList<>();
        for(int i=0;i<str1.length();i++){
        	lists.add(str1.charAt(i));
        }
        for(int i=0;i<str2.length();i++){
            if(lists.contains(str2.charAt(i))) return false;
        }
        return true;
    }

}
